import shutil, os, sys
from pathlib import Path
import datetime
import updateModelParamsUtils,  MyUtils

def demo(publish,srcProductPath="product1/model", dstModelPathList=['product1/model', 'product2/model'],commitInfo="xxx",stepIdxListNot=[]):
    #rootPath = 'E:/workspace/0_model/0_shenzhenHuaxing_piantie-new/'
     modelName = srcProductPath.split('/')[-1]
     srcModelPath = srcProductPath
     if( not os.path.exists(srcModelPath)):
            print("srcModelPath path not exist: ", srcModelPath)
            exit(0)
     else:
         print(">>> src model: ", srcModelPath)
         print(">>>")

     dstModelPathList = dstModelPathList
    
     

     updateModelParamsUtils.modelUpdateDemo(commitInfo, srcModelPath,dstModelPathList,stepIdxListNot,publish)

def CG():
    rootPath = 'E:\\workspace\\0_model\\越南夏普\\夏普模组\\edge-4k/'
    dstProductsList=[
         #2线
            #"CG-12.0矩形2"
            #,"CG-12.2矩形2"
             

             "CG-12.0矩形有壳2"
             ,"CG-12.2矩形有壳2"
                    
        #3线    
            #,"CG-12.2异形3"
            #,"CG-16.3矩形3"
            #,"CG-16.3异形3"

            ,"CG-12.2异形有壳3"
            ,"CG-16.3矩形有壳3"
            ,"CG-16.3异形有壳3"
                     ]
    
    prefix = "model-"  #model名称的前缀
    publish = None
    publish = rootPath
    stepIdxListNot = [
          #测量step
          146,157,139,125   #位置自定义
          ,150,132, 138,126  #测量边自定义

     ]

    #编辑参数####################################################
    srcProduct="CG-12.0矩形有壳2"
    commitInfo = "缝隙测量内边黑缝"
    #编辑参数####################################################


    print("commitInfo: ", commitInfo)
    print("发布model：", publish)
    inputStr = input("当前源model："+srcProduct+"\n是否确认更新(y/n): ")
    print(inputStr)
    if inputStr != 'y':
        print("指令错误: " + inputStr)
        exit(0)

    commitInfo = commitInfo+", 同步model-"+srcProduct

    dstModelPathList = []
    for dstProducts in dstProductsList:
        dstModelPathList.append(rootPath+dstProducts+"/"+prefix+dstProducts+"/")
    
    srcProductPath=rootPath+srcProduct+"/"+prefix+srcProduct+"/"
    demo(publish=publish,srcProductPath=srcProductPath, 
        dstModelPathList=dstModelPathList,commitInfo=commitInfo,stepIdxListNot=stepIdxListNot)
    
    print("commitInfo: ", commitInfo)
    print("发布model：", publish)
    
if __name__ == "__main__":  
    currentTime = datetime.datetime.now().strftime('%Y-%m-%d  %H:%M:%S')
    currentDate = datetime.datetime.now().strftime('%Y-%m-%d')

    CG()

    exit(0)


    
